package com.doit.mr.day03;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @DATE 2021/12/8/17:16
 * @Author MDK
 * @Version 2021.2.2
 **/
public class WordCountReducer extends Reducer<Text, IntWritable, Text, IntWritable> {
    @Override
    protected void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
        int cnt = 0;
        for (IntWritable value : values) {
            cnt++;
        }
//        IntWritable v = new IntWritable();
//        v.set(cnt);
//        context.write(key,v);
        context.write(key,new IntWritable(cnt));
    }
}
